<?php

declare(strict_types=1);

namespace app\api\controller\v1;

use app\common\Frontend;
use app\common\model\FooterNav;
use app\common\model\PublicStatus;
use general\Tree;
use think\Request;

class Nav extends Frontend
{

    protected array $noNeedLogin = ['footerNav','footerOtherNav'];
    public function initialize(): void
    {
        parent::initialize();
    }


    //底部菜单
    public function footerNav() : void {
        $res = FooterNav::where(['status'=>PublicStatus::PUBLIC_STATUS_ONE,'type'=>PublicStatus::PUBLIC_STATUS_ONE])->select()->toArray();
        $other = FooterNav::where(['status'=>PublicStatus::PUBLIC_STATUS_ONE,'type'=>PublicStatus::PUBLIC_TWO])->select()->toArray();
        $data = Tree::instance()->assembleChild($res);
        $other_data =  Tree::instance()->assembleChild($other);
        $this->success('', [
            'list' => [
                'result'=>$data,
                'other'=>$other_data
            ],
            'remark' => '',
        ]);
    }
    //底部其他菜单
    public function footerOtherNav() : void {
        $res = FooterNav::where(['status'=>PublicStatus::PUBLIC_STATUS_ONE,'type'=>PublicStatus::PUBLIC_TWO])->select()->toArray();
        $data = Tree::instance()->assembleChild($res);
        $this->success('', [
            'list'   => $data,
            'remark' => '',
        ]);
    }

}
